﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Enterprise.Infrastructure;
namespace Enterprise.UI.Web.Modules.Json
{
    public partial class UserList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string selected = (string)Utility.sink("selected", Utility.MethodType.Get, 0, 0, Utility.DataType.Str);
            string json = ""; 
            Response.Clear();
            DataTable dt = new DataTable();
            #region TestData
            ////从数据库获取用户数据生成Json            
            //dt.Columns.Add("userId",typeof(int));
            //dt.Columns.Add("userName", typeof(string));
            //dt.Columns.Add("userNameRu",typeof(string));
            //dt.Columns.Add("deptId", typeof(int));
            //dt.Columns.Add("deptName", typeof(string));
            //dt.Columns.Add("deptParentId",typeof(int));
            //dt.Columns.Add("sex", typeof(string));
            //dt.Columns.Add("isdept", typeof(int));

            //DataRow dr = dt.NewRow();
            //dr[0] = 1;
            //dr[1] = "公司领导";
            //dr[2] = "Leaders";
            //dr[3] = 1;
            //dr[4] = "公司领导";
            //dr[5] = 0;
            //dr[6] = "";
            //dr[7] = 1;
            //dt.Rows.Add(dr);


            //dr = dt.NewRow();
            //dr[0] = 2;
            //dr[1] = "张玉梅";
            //dr[2] = "Robin.Smith";
            //dr[3] = 1;
            //dr[4]="公司领导";
            //dr[5] = 1;
            //dr[6] = "女";
            //dr[7] = 0;
            //dt.Rows.Add(dr);

            //dr = dt.NewRow();
            //dr[0] = 3;
            //dr[1] = "李中国";
            //dr[2] = "Loaria.Smith";
            //dr[3] = 1;
            //dr[4] = "公司领导";
            //dr[5] = 1;
            //dr[6] = "男";
            //dr[7] = 0;
            //dt.Rows.Add(dr);

            //dr = dt.NewRow();
            //dr[0] = 4;
            //dr[1] = "网络中心";
            //dr[2] = "Loaria.Smith";
            //dr[3] = 1;
            //dr[4] = "公司领导";
            //dr[5] = 0;
            //dr[6] = "男";
            //dr[7] = 1;
            //dt.Rows.Add(dr);
            #endregion
            Enterprise.Service.User.UserService us = new Service.User.UserService();
            dt = us.GetRelationForCombox().Tables[0];
            json = dt.ToJsonForEasyuiComboTree("CID", "TEXT", "PARENTID", "d-0", selected);
            Response.Write(json);
            Response.End();
        }
    }
}